import cv2
import os
from tqdm import tqdm
import numpy as np
import json

imgpath = "data/side/test"
savepath = "data/side/halftest/"


if not os.path.exists(savepath):
    os.makedirs(savepath)

imglist = os.listdir(imgpath)
for imgname in imglist:
    # print(imgname)
    img = cv2.imread(os.path.join(imgpath,imgname))
    w = img.shape[1]
    imgl = img[:, :w // 2]
    imgr = img[:, w // 2:]
    imgnamel = os.path.join(savepath, imgname[:-4] + 'l.jpg')
    imgnamer = os.path.join(savepath, imgname[:-4] + 'r.jpg')
    cv2.imwrite(imgnamel,imgl)
    cv2.imwrite(imgnamer,imgr)


